package blogs3;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class BufferedReaderFileRreader {
	public static void convertGBK2UTF8(String src, String dst) throws IOException{
		try {
			BufferedReader  br=new BufferedReader(new FileReader(src));
			OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream(dst));
			while(br.readLine()!=null){
				osw.write(br.readLine());
			}
			br.close();
			osw.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch(IOException e1){
			e1.printStackTrace();
		}
			
		
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FileInputStream fis = null;
		InputStreamReader isr = null;
		BufferedReader br = null;
		try {

			fis = new FileInputStream("D:/EncodeTest.txt");
			isr = new InputStreamReader(fis, "GBK");
			br = new BufferedReader(isr);
			while (br.readLine() != null) {
				System.out.println(br.readLine());
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
	
}
